package io.github.wanggit.antcms.server.web.vm;

import io.github.wanggit.antcms.server.Constants;

import java.io.Serializable;

public class Result implements Serializable {

    private int code;

    private String msg;

    private Object data;

    public static Result ok() {
        Result result = new Result();
        result.setCode(Constants.SUCCESS);
        return result;
    }

    public static Result ok(Object data) {
        Result result = new Result();
        result.setCode(Constants.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.setCode(Constants.ERROR);
        return result;
    }

    public static Result error(String errorMessage) {
        Result result = new Result();
        result.setCode(Constants.ERROR);
        result.setMsg(errorMessage);
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
